package cn.linran.controller;

import cn.linran.domain.Store;
import cn.linran.service.IStoreService;
import cn.linran.util.jsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/store")
public class StoreController {
    @Autowired
    private IStoreService iStoreService;
    @GetMapping("/findById/{id}")
    public Store  findById(@PathVariable("id")Long id){
        return iStoreService.findById(id);
    }
    @PostMapping("/add")
    public jsonResult add(@RequestBody Store store){
        try {
            iStoreService.add(store);
            return jsonResult.me().setResultObj(store);
        } catch (Exception e) {
            e.printStackTrace();
            return jsonResult.me().setResultObj("王诺拥堵");
        }
    }
}
